<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // let custom = new CustomEvent('test_event', { detail: { e_name: " this is a test " } })// 某个dom元素监听自定义事件
        let div = document.createElement("DIV");
        div.addEventListener("test_event", function (e) {
            console.log(e)
        }, false)// 触发自定义事件（dispatchEvent 除非事件的参数是必填项，切必须为事件对象）
        // div.dispatchEvent(custom);// this is a test
        // div.dispatchEvent(new CustomEvent('test_event',{detail:{e_name:"HelloWorld!"}}));// this is a test
        div.dispatchEvent(new Event('test_event'));// this is a test
    </script>
</body>

</html>